<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-eval' 'unsafe-inline';">
<title>管理后台 - <?= $systemConfig['system_name'] ?? '实名认证分发系统' ?></title>
<link rel="stylesheet" href="/layui/css/layui.css">
<link rel="stylesheet" href="/static/css/admin.css">
<script src="/static/js/jquery.min.js"></script>
<script src="/layui/layui.js"></script>
</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
    <div class="layui-header">
        <div class="layui-logo layui-hide-xs layui-bg-black"><?= $systemConfig['system_name'] ?? '实名认证分发系统' ?></div>
        <ul class="layui-nav layui-layout-right">
            <li class="layui-nav-item"><a href="/" target="_blank"><i class="layui-icon layui-icon-website"></i> 前台首页</a></li>
            <li class="layui-nav-item"><a href="javascript:;"><?= $adminInfo['nickname'] ?? $adminInfo['username'] ?? '管理员' ?></a>
                <dl class="layui-nav-child"><dd><a href="javascript:void(0)" onclick="modifyPassword()">修改密码</a></dd><dd><a href="/admin/index/logout">退出登录</a></dd></dl>
            </li>
        </ul>
    </div>
    <div class="layui-side layui-bg-black">
        <div class="layui-side-scroll">
            <ul class="layui-nav layui-nav-tree" lay-filter="adminMenu">
                <?php foreach ($menuConfig as $menu): ?>
                <?php if (isset($menu['children'])): ?>
                <li class="layui-nav-item"><a href="javascript:;"><i class="layui-icon <?= $menu['icon'] ?>"></i> <?= $menu['title'] ?></a>
                    <dl class="layui-nav-child"><?php foreach ($menu['children'] as $child): ?><dd><a href="<?= $child['url'] ?>" target="mainFrame"><?= $child['title'] ?></a></dd><?php endforeach; ?></dl>
                </li>
                <?php else: ?>
                <li class="layui-nav-item"><a href="<?= $menu['url'] ?>" target="<?= $menu['key'] === 'home' ? '_blank' : 'mainFrame' ?>"><i class="layui-icon <?= $menu['icon'] ?>"></i> <?= $menu['title'] ?></a></li>
                <?php endif; ?>
                <?php endforeach; ?>
            </ul>
        </div>
    </div>
    <div class="layui-body"><iframe name="mainFrame" src="/admin/index/main" frameborder="0" style="width:100%;height:100%;border:none;"></iframe></div>
    <div class="layui-footer" style="text-align:center;"><?= $systemConfig['copyright'] ?? '' ?></div>
</div>
<div id="passwordModal" style="display:none;padding:20px;">
    <form class="layui-form" lay-filter="passwordForm">
        <div class="layui-form-item"><label class="layui-form-label">原密码</label><div class="layui-input-block"><input type="password" name="old_password" lay-verify="required" placeholder="请输入原密码" class="layui-input"></div></div>
        <div class="layui-form-item"><label class="layui-form-label">新密码</label><div class="layui-input-block"><input type="password" name="new_password" lay-verify="required|pass" placeholder="请输入新密码" class="layui-input"></div></div>
        <div class="layui-form-item"><label class="layui-form-label">确认密码</label><div class="layui-input-block"><input type="password" name="confirm_password" lay-verify="required|pass" placeholder="请确认新密码" class="layui-input"></div></div>
    </form>
</div>
<script>
layui.use(['element','form','layer'],function(){var el=layui.element,f=layui.form,l=layui.layer;
f.verify({pass:[/^[\S]{6,20}$/,'密码必须6到20位，且不能出现空格']});
modifyPassword=function(){l.open({type:1,title:'修改密码',area:['450px','320px'],content:$('#passwordModal'),btn:['确定','取消'],yes:function(idx){
var o=$('input[name="old_password"]').val(),n=$('input[name="new_password"]').val(),c=$('input[name="confirm_password"]').val();
if(n!==c){l.msg('两次密码不一致');return;}$.post('/admin/system/modifyPassword',{old_password:o,new_password:n,confirm_password:c},function(r){if(r.code===0){l.msg(r.msg,{icon:1});l.close(idx);}else l.msg(r.msg,{icon:2});});}});};
});
</script>
</body>
</html>